
*** This do file generates panel B of figure B10 in the minimum wage precommitment paper

*** BJS event study using the year of first statutory increase as the first treatment year 
*** low-skilled individuals with sparse controls, combine large and small statutory increasers

* Drop all states that were originally indexers

set more off
cap log close
clear all

graph drop _all

* If needed change global path to point to directory where files are stored on your computer
*global path "I:/DataSets5/Duncan/Dropbox/Recent Minimum Wage Changes/2020.12 NBER Update/JOLE Precommittment Replication"
global dtadir "$path/Data"
global tabdir "$path/Tables"
global figdir "$path/Figures"
global estdir "$path/Estimates"
global logdir "$path/Logfiles"

log using "$logdir/BJS-prime-age-sparse-controls-drop-indexers.log", replace

* Load data
use "${path}/Data/ACSEventStudiesData.dta", replace

* Generate sample dummies
gen lowskill = 0
replace lowskill = 1 if dropout == 1 & inrange(age,16,25)

gen young = 0
replace young = 1 if inrange(age,16,21)

gen primeage = 0
replace primeage = 1 if inrange(age,26,54)

gen primeagehighskill = 0 
replace primeagehighskill = 1 if inrange(age,26,54) & educ > 6 & !missing(educ)

* Drop all states that were originally indexers
drop if indexer == 1

* Gen ID for each oabservation
gen id = _n

* Generate relative periods
gen K = year - legimpyear1

est clear

set seed 123456

* Prime-age No Controls
keep if primeage == 1

* Manually bin distant periods using wtr function
count if K == 0
gen tau0 = (K== 0)/r(N)
count if K == 1
gen tau1 = (K==1)/r(N)
count if K == 2
gen tau2 = (K==2)/r(N)
count if K == 3
gen tau3 = (K==3)/r(N)
count if K >= 4 & !missing(K)
gen tau4 = (K>=4 & !missing(K))/r(N)

* Prime Age sparse Controls
did_imputation employed id year legimpyear1 [aw=cmpwgt], wtr(tau0 tau1 tau2 tau3 tau4) controls(HPI lnPersonalIncome) fe(statefip year) cluster(statefip) pretrends(3) maxit(1000) verbose
estimates store primeage_sparse

event_plot primeage_sparse, together plottype(scatter) ciplottype(rspike) savecoef stub_lag(tau_tau#) noautolegend ///
	graph_opt(title("Panel B: Prime Age with Sparse Controls", size(medsmall)) ytitle("", size(small)) xtitle("", size(small)) ///
	xlabel(-3 "-3" -2 "-2" -1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4+", labsize(small)) ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xline(-0.5, lpattern(dash) lcolor(black)) yline(0, lpattern(solid) lcolor(black)) bgcolor(white) graphregion(color(white)) /// 
	legend(order(1 "All Statutory Increasers") region(lstyle(none)) rows(1) size(small) symxsize(small) symysize(small)) name(primeage_sparse, replace) scheme(s2mono)) ///
	lag_opt(color(black)) lead_opt(color(black)) lag_ci_opt(color(black black)) lead_ci_opt(color(black black))
	graph save "$figdir/BJS/primeage-base-controls-drop-indexers.gph", replace

esttab primeage_sparse using "$figdir/BJS/prime-age-base-controls-drop-indexers.csv", replace order(pre* tau*) wide noparentheses ///
	b(3) ci(3) ar(3) star(* 0.10 ** 0.05 *** 0.01) compress nogap noconstant mtitles("All Increasers") ///
	scalars("pre_p Pretrend p-value" "pre_F Pretrend F Statistic")